package com.relife.core.dao;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import com.relife.common.model.Page;
import com.relife.core.qbc.QbcQuery;
import org.hibernate.Criteria;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;



public interface IBaseDao {

	public <T> void save(T entity);

	public <T> void update(T entity);

	public int update(String sql, Object... objs);

	/**
	 * 无返回值，适用于create和drop table。
	 * 
	 * @author WU
	 * @date 2017年3月13日 下午9:19:29
	 * @param sql
	 */
	public void execute(String sql);

	public <T> void saveOrUpdate(T entity);

	public <T> void merge(T entity);

	public <T> void delete(T entity);

	public <T> void updateOrSaveList(List<T> list);

	public <T> void deleteList(List<T> list);

	public void flush();

	public void clear();

	public <T> Criteria createCriteria(Class<T> cl);

	public <T> T load(Class<T> cl, Serializable id);

	public <T> T get(Class<T> cl, Serializable id);

	public <T> T getByHql(String hql, Serializable id);

	public <T> T get(Class<T> cl, String propertyName, Object value);

	public <T> T get(DetachedCriteria dc);

	public <T> T get(QbcQuery qbc);

	public <T> T get(Class<T> cl, String sql, Object... objs);

	public Map<String, Object> get(String sql, Object... objs);

	public <T> List<T> getList(Class<T> cl, Serializable[] ids);

	public <T> List<T> getList(Class<T> cl, String propertyName, Object value);

	public <T> List<T> getList(Class<T> cl, String propertyName, Object value, Order order);

	public <T> List<T> getList(T t, Order order);

	public <T> List<T> getList(QbcQuery qbc);

	public <T> List<T> getListByHql(String hql, Object... objs);

	public <T> List<T> getList(Class<T> cl, Order order);

	public List<Map<String, Object>> getList(String sql, Object... objs);

	public <T> Page getPage(T entity, Page page, Order order);

	public Page getPage(Page page, DetachedCriteria dc);

	public Page getPage(QbcQuery qbc, Page page);

	public Page getPage(String sql, Page page, Object... objs);

	public Integer getCountJdbc(String sql, Object... obj);

	public Integer getCount(QbcQuery qbc);

	public <T> Integer getMax(Class<T> cl, String propertyName);
}
